#ifndef tk_cfg_json_h__
#define tk_cfg_json_h__
#include "tk_data_type.hpp"
#include "tk_mutex.hpp"
#include "tk_filesystem.h"
#include "../../3th_party/rapidjson/include/rapidjson/document.h"
using namespace rapidjson;

namespace tk{

	typedef GenericDocument<UTF16<> > WDocument;
	typedef GenericValue<UTF16<> > WValue;

	class tk_cfg_json
	{
	public:
		tk_cfg_json() {}
		~tk_cfg_json() {}
		tk_bool Attach(const tk_pwchar path, tk_pwchar bk_path = 0){
			if (!PathIsExist(tk_wstring(path))){
				return false;
			}

		}

		bool Save(void);
		bool CopyFrom(const tk_cfg_json &other);

	protected:
		bool AttachOpen(void);
		bool LoadFile(void);
		bool SaveFile(void);
		void CreateNew();

		static void InsertChild(WValue &parent,tk_wstring &key,WValue &child);


		tk_wstring m_file_path;
		tk_wstring m_bk_file_path;
		WDocument m_doc;
		boost_mutex m_mutex;
	private:
		
	};




}//namespace tk



#endif // tk_cfg_json_h__
